<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = [10, 20, 30, 40, 50];
      function myFilter(fn) {
        var arr = [];
        for (var i = 0; i < this.length; i++) {
          if (fn(this[i], i, this)) {
            arr.push(this[i]);
          }
        }
        return arr;
      }

      Array.prototype.myFilter = myFilter;
      console.log(
        arr.myFilter(function (item, i, arr) {
          return item > 20;
        })
      );
    </script>
  </body>
</html>
